package cn.com.ejiakanghu.web;

import cn.com.ejiakanghu.annotation.LoginUser;
import cn.com.ejiakanghu.core.utils.RespUtil;
import cn.com.ejiakanghu.core.vo.BaseResult;
import cn.com.ejiakanghu.service.AgentManager;
import cn.com.ejiakanghu.service.HomeManager;
import cn.com.ejiakanghu.vo.HospitalLinkDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 首页相关
 * @author houzb
 * @Description
 * @create 2021-03-29 19:08
 */
@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private HomeManager homeManager;

    /**
     *
     * @api {get} /home/data 获取首页数据
     * @apiParam {String} city 城市名，服务器根据城市名返回首页数据，不传该参数或该参数为空字符串，服务器可返回默认城市对应的数据或全国的数据
     * @apiGroup 首页
     * @apiVersion 0.1.0
     * @apiDescription 获取首页需要展示的数据内容
     * @apiSuccess {int} code 请求状态码，0表示成功,其它参考状态码文档
     * @apiSuccess {String} message 结果消息说明
     * @apiSuccess {boolean} success 请求是否成功
     * @apiSuccess {Object} data 请求响应的数据
     * @apiSuccessExample {json} Success-Response:
     * {
     *     "code": "请求状态码，0表示成功，其它参考状态码文档",
     *     "success": "请求是否成功",
     *     "timestamp": "服务器当前时间戳10位精确到秒",
     *     "message": "请求成功/失败说明",
     *     "data": {
     *         "noticeList": [{
     *             "content": "公告内容，长度20个汉字以内"
     *         }],
     *         "hotkeyList": [{
     *             "keyword": "关键字，例如：手动轮椅"
     *         }],
     *         "bannerList": [{
     *             "image": "广告图片URL，图片宽高尺寸比例：710x248",
     *             "event": "广告点击事件类型",
     *             "url": "广告点击事件参数：小程序页面地址或完整的网页URL"
     *         }],
     *         "specialList": [{
     *             "id": "专题ID",
     *             "name": "专题分类名称，长度建议4个汉字以内",
     *             "tag": "专题红色标签，长度建议6个汉字以内",
     *             "goodsList": [{
     *                 "id": "商品ID",
     *                 "name": "商品名称",
     *                 "mainImage": "商品主图URL，图片宽高尺寸比例：320x320",
     *                 "type": "商品类型",
     *                 "tags": [{
     *                     "tag": "商品标签文本，例如：送货上门",
     *                     "isRed": "是否标红显示"
     *                 }],
     *                 "priceInfo": [{
     *                     "price": "商品价格，精确到分，例如：18.00",
     *                     "suffix": "显示价格后缀，例如：/天起、/元起（可选项）",
     *                     "linePrice": "显示划线价格，精确到分，例如：22.00（可选项）",
     *                     "deposit": "商品预付金（押金/租金）价格，精确到分"
     *                 }],
     *                 "isOffline": "商品是否已下架",
     *                 "isInvalid": "商品是否已失效，商品可以看但不能购买",
     *                 "isDisabled": "商品是否不支持购买，商品可以看但不能买",
     *                 "deductNum": "购买或租赁当前商品可获得的抵扣金数量"
     *             }]
     *         }],
     *         "homeRecommend": {
     *             "hotleaseList": [{
     *                 "id": "商品ID",
     *                 "name": "商品名称",
     *                 "mianImage": "商品主图URL，图片宽高尺寸比例：320x320",
     *                 "type": "商品类型",
     *                 "isMany": "是否显示万人租标签"
     *             }],
     *             "hotsaleList": [{
     *                 "id": "商品ID",
     *                 "name": "商品名称",
     *                 "mianImage": "商品主图URL，图片宽高尺寸比例：320x320",
     *                 "type": "商品类型",
     *                 "isMany": "是否显示万人买标签"
     *             }]
     *         }
     *     }
     * }
     */

    @RequestMapping("/data")
    public BaseResult getHomeData(Integer saleUserId,@LoginUser Integer userId,HttpServletRequest request) {
        return homeManager.getHomeData(saleUserId,userId,request);
    }


    /**
     * 获取医院推广链接数据（第三方公众号入口、第三方小程序入口、推广二维码入口）
     * @param hospitalLinkDataVo
     * @return
     */
    @RequestMapping("/getHospitalLinkData")
    public BaseResult getHospitalLinkData(@Validated HospitalLinkDataVo hospitalLinkDataVo){
        return homeManager.getHospitalLinkData(hospitalLinkDataVo);
    }
}
